//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<engine.h>
///	@path	~/src/engine/
///	@date	2007/07/07
///	@desc	engine API declarations.

#pragma once

#include "xeres.h"

#include "lib/utilities/callback.h"
#include "lib/system/tls.h"

namespace xeres {

	// forward declaration
	class Engine;

	/*!
		\class	EngineContext
		\brief	Engine calling context.
				Xeres does not use global variable as Engine accessing form.
				Instead, we provide an EngineContext class which exist in TLS,
				to provide a more secure way of accessing engine.
				Notice works run inside main thread should also be considered as a generic thread.
				DON'T try to assume any works run inside main thread can avoid threading problem.
	*/
	class EngineContext
	{
	public:

		/// \instance
		static EngineContext& instance( void );

		/*!
		*/

	private:

		// for engine access only
		friend class Engine;

		/// \ctor
		EngineContext( Engine& engine );

		/// \dtor
		~EngineContext( void );

	//@ data

		Engine&			m_engine;
	};

} // namespace xeres
